import Vue from 'vue'
import App from './App.vue'
import router from './router/routers'
import store from './store'

import Cookies from 'js-cookie'
import Element from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import i18n from './lang' // internationalization

import Header from "@/components/Front/Header.vue";
import Footer from "@/components/Front/Footer.vue";
import SearchPopup from "@/components/Front/SearchPopup.vue";
import MobileHeader from "@/components/Front/MobileHeader.vue";
import Preloader from "@/components/Front/Preloader.vue";
import ScrollTop from "@/components/Front/ScrollTop.vue";
import MiniCart from "@/components/MiniCart/main.vue";
import AddressForm from "@/components/AddressForm/index.vue";

// import MiniCart from "@/components/MiniCart/index.js";
// 全局组件注册
const components = [Header, Footer, SearchPopup, MobileHeader, Preloader, ScrollTop, MiniCart, AddressForm];
components.forEach(component => {
  Vue.component(component.name, component);
});

Vue.use(Element, {
  size: Cookies.get('size') || 'medium', // set element-ui default size
  i18n: (key, value) => i18n.t(key, value)
})
Vue.use(MiniCart)

Vue.config.productionTip = false

new Vue({
  router,
  store,
  i18n,
  render: h => h(App),
}).$mount('#app')

// $(document).ready(function (e) {
//   var counter = 0;
//   if (window.history && window.history.pushState) {
//     $(window).on('popstate', function () {
//       window.history.pushState('forward', null, '#');
//       window.history.forward(1);
//       alert("不可回退");
//     });
//   }

//   window.history.pushState('forward', null, '#'); //在IE中必须得有这两行
//   window.history.forward(1);
// });